# Copyright 2022 Ant Group Co., Ltd.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
#   http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

load("@rules_cc//cc:defs.bzl", "cc_proto_library")
load("//bazel:yacl.bzl", "yacl_cc_library", "yacl_cc_test")

package(default_visibility = ["//visibility:public"])

yacl_cc_library(
    name = "channel",
    srcs = ["channel.cc"],
    hdrs = ["channel.h"],
    deps = [
        "//yacl/base:buffer",
        "//yacl/base:byte_container_view",
        "//yacl/base:exception",
        "//yacl/link:retry_options",
        "//yacl/link:ssl_options",
        "//yacl/utils:segment_tree",
        "@brpc",
    ],
)

yacl_cc_test(
    name = "channel_test",
    srcs = ["channel_test.cc"],
    deps = [
        ":channel",
        ":ic_transport_proto",
    ],
)

yacl_cc_library(
    name = "channel_mem",
    srcs = ["channel_mem.cc"],
    hdrs = ["channel_mem.h"],
    deps = [
        ":channel",
    ],
)

yacl_cc_test(
    name = "channel_mem_test",
    srcs = ["channel_mem_test.cc"],
    deps = [
        ":channel_mem",
    ],
)

cc_proto_library(
    name = "ic_transport_proto",
    deps = ["@org_interconnection//interconnection/link"],
)

yacl_cc_library(
    name = "interconnection_link",
    srcs = ["interconnection_link.cc"],
    hdrs = ["interconnection_link.h"],
    deps = [
        ":channel",
        ":ic_transport_proto",
    ],
)

yacl_cc_library(
    name = "brpc_link",
    srcs = ["brpc_link.cc"],
    hdrs = ["brpc_link.h"],
    deps = [
        ":interconnection_link",
    ],
)

yacl_cc_test(
    name = "brpc_link_test",
    srcs = ["brpc_link_test.cc"],
    deps = [
        ":brpc_link",
    ],
)

yacl_cc_library(
    name = "brpc_blackbox_link",
    srcs = ["brpc_blackbox_link.cc"],
    hdrs = ["brpc_blackbox_link.h"],
    deps = [
        ":interconnection_link",
        "//yacl/link/transport/blackbox_interconnect:blackbox_service_errorcode",
        "//yacl/link/transport/blackbox_interconnect:blackbox_service_proto",
    ],
)

yacl_cc_test(
    name = "brpc_blackbox_link_test",
    srcs = ["brpc_blackbox_link_test.cc"],
    deps = [
        ":brpc_blackbox_link",
        "//yacl/link/transport/blackbox_interconnect:blackbox_dummy_service_proto",
    ],
)
